package com.wlz.creational.abstractfactory;

import com.wlz.creational.abstractfactory.app.Application;
import com.wlz.creational.abstractfactory.factories.GUIFactory;
import com.wlz.creational.abstractfactory.factories.MacOSFactory;
import com.wlz.creational.abstractfactory.factories.WindowsFactory;

/**
 * @author： wlz
 * @Date 2020/10/14 13:48
 * @description： TODO
 * @version: 1.0
 */
public class Demo {

    public static void main(String[] args) {

        Application app = configureApplication();
        app.paint();
    }

    private static Application configureApplication() {
        Application app;
        GUIFactory factory;

        String osName = System.getProperty("os.name").toLowerCase();
        if (osName.contains("mac")) {
            factory = new MacOSFactory();
            app = new Application(factory);
        }else {
            factory = new WindowsFactory();
            app = new Application(factory);
        }
        return app;
    }
}
